package com.example.demo.po;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Data
@TableName("credit")
public class Credit implements java.io.Serializable{
    private static final long serialVersionUID = 1235L;
    @TableId
    private String cardNumber;
    @TableField(value = "card_expire_date")
    private String cardCvv;
    @TableField(value = "user_id")
    private Long userId;
    @TableField(value = "balance")
    private Double balance;
    @TableField(value = "version")
    private Integer version;
    @TableField(value = "expire_date")
    private LocalDate expire_date;
    @TableField(value = "status")
    private  Integer status;
    @TableField(value = "create_time")
    private LocalDateTime create_time;
    @TableField(value = "update_time")
    private LocalDateTime update_time;
    @TableField(value = "deleted")
    private Integer deleted;
    public String getFormattedDate() {
        return expire_date.format(DEFAULT_FORMATTER);
    }
    // DateTime 的格式化方法
    public String getFormattedDateTime() {
        update_time.format(DEFAULT_FORMATTER);
        return create_time.format(DATETIME_FORMATTER);
    }
    private static final DateTimeFormatter DEFAULT_FORMATTER =
            DateTimeFormatter.ofPattern("yyyy-MM-dd");
    private static final DateTimeFormatter DATETIME_FORMATTER =
            DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
}
